﻿@{
    Layout = null;
}
@model System.Collections.IEnumerable
<!DOCTYPE html>
<html>
<head>
@*<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"/>*@
<title></title>
@if (false)
{
    <script src="../../../../Scripts/jquery-vsdoc.js" type="text/javascript"></script> 
    <script src="../../../../Scripts/ASPxScriptIntelliSense.js" type="text/javascript"></script>     
}

<link href="@Url.Content("~/Content/Site.css", true)" rel="stylesheet" type="text/css" />
<script src="@Url.Content("~/Scripts/jquery.min.js", true)" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/FloatDiv.js", true)" type="text/javascript"></script>
<script src="@Url.Content("~/Common/GetRootPath.ashx", true)" type="text/javascript"></script>


@Html.DevExpress().GetStyleSheets(
        new StyleSheet { ExtensionType = ExtensionType.GridView, Theme = DevExpressHelper.Theme }
)


@Html.DevExpress().GetScripts(
        new Script { ExtensionType = ExtensionType.ListBox }
)



<script type="text/javascript">

    $(function () {
        $("#toolMenu").smartFloat();
    });

    function OnBeginCallback(s, e) {
        e.customArgs["command"] = e.command;
        e.customArgs["pageIndex"] = s.pageIndex;
        e.customArgs["pageCount"] = s.pageCount;
        e.customArgs["pageRowSize"] = s.pageRowSize;
        e.customArgs["pageRowCount"] = s.pageRowCount;
        e.customArgs["albumId"] = $('#hdalbumId').val();

    }



    function MenuTop_emClick(source, e) {
        switch (e.item.name) {
            case "btnPhoto":
                {
                    //上传照片 
                    //photoModalMode.SetContentUrl("/Admin/DocManager/MediaUpload?dirID=" + $('#hidDirId').val() + "&type=pic&docID=" + $('#hidDocId').val());
                    $('#photoContent').attr("src", rootPath + "/Admin/Album/MediaUpload?albumClsNo=" + $('#hdalbumClsNo').val() + "&type=pic&albumId=" + $('#hdalbumId').val());
                    photoModalMode.Show();
                    break;
                }
            case "btnDelMany":
                {
                    lpModal.Show();
                    //批量删除
                    var entryids = "";
                    $('[id$="_*"]').each(function () {
                        var id = $(this).attr('id');
                        var chkBox = ASPxClientCheckBox.Cast(id);
                        if (chkBox.GetChecked()) {
                            entryids += id.split('_')[1] + ",";
                        }
                    });

                    if (entryids == "") {
                        alert("请选择要删除的数据");
                        lpModal.Hide();
                    } else {
                        if (confirm("确定删除选择的数据")) {
                            $.ajax({
                                type: 'POST',
                                url: rootPath + '/Admin/Album/EntryDelMany',
                                data: { entryIDs: entryids },
                                success: function (result) {
                                    lpModal.Hide();
                                    if (result == "ok") {
                                        alert("删除成功");
                                        gvEditing.Refresh();
                                    } else {
                                        alert(result);
                                    }
                                }
                            });

                        } else {
                            lpModal.Hide();
                        }
                    }


                    break;
                }
        }
    }


    function edit(entryID) {
        //picEditModalMode.SetContentUrl("/Admin/DocManager/PicEdit?entryID=" + entryID);
        $('#picEditContent').attr("src", rootPath + "/Admin/Album/PicEdit?entryID=" + entryID);
        picEditModalMode.Show();
    }

    function picEditModalModeOK() {
        gvEditing.Refresh();
        alert("保存成功");
        picEditModalMode.Hide();
    }

    function picEditModalModeCancel() {
        picEditModalMode.Hide();
    }



    function del(entryID) {
        if (confirm("确定删除?")) {
            $.ajax({
                type: 'POST',
                url: rootPath + '/Admin/Album/EntryDel',
                data: { entryID: entryID },
                success: function (result) {
                    if (result == "ok") {
                        alert("删除成功");
                        gvEditing.Refresh();
                    } else {
                        alert(result);
                    }
                }
            });
        }
    }

    function selectAll(s, e) {
        var bl = s.GetChecked();
        $('[id$="_*"]').each(function () {
            var id = $(this).attr('id');
            var chkBox = ASPxClientCheckBox.Cast(id);
            chkBox.SetChecked(bl);
        });

    }



    function SetModel() {
        lpLoad.Show();
    }


    function swfUploadOK() {
        lpModal.Show();
        alert("保存成功");
        window.location.href = rootPath + "/Admin/Album/PicList?albumId=" + $('#hdalbumId').val() + "&albumClsNo=" + $('#hdalbumClsNo').val();
    }

</script>


</head>

<body>

<div class="floatToolMenu" id="toolMenu">
       @Html.DevExpress().Menu(settings =>
  {
      settings.Name = "toolBarMenu";
      settings.ItemAutoWidth = false;
      settings.Width = System.Web.UI.WebControls.Unit.Percentage(100);
      settings.Styles.Style.Border.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(0);
      settings.Styles.Style.BorderTop.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(1);

      settings.Items.Add(item =>
      {
          item.Name = "btnAdd";
          item.Text = "新建";
          item.ClientEnabled = true;
          item.Image.Url = Url.Content("~/Content/ControlImages/edit_add.png");
          item.Items.Add(childItem =>
          {
              childItem.Name = "btnPhoto";
              childItem.Text = "上传照片";
              childItem.ClientEnabled = true;
              childItem.Image.Url = Url.Content("~/Content/ControlImages/picture_add.png");
          });

      });
      //settings.Items.Add(item =>
      //{
      //    item.Name = "btnSort";
      //    item.Text = "排序";
      //    item.Visible = (bool)ViewData["FW"];
      //    item.ClientEnabled = true;
      //    item.Image.Url = Url.Content("~/Content/ControlImages/sort.png");

      //});
      settings.Items.Add(item =>
      {
          item.Name = "btnDelMany";
          item.Text = "批量删除";
          item.ClientEnabled = true;
          item.ItemStyle.ForeColor = System.Drawing.Color.Red;
          item.Image.Url = Url.Content("~/Content/ControlImages/deleteMany.png");

      });
      settings.ClientSideEvents.ItemClick = "function(source,e){MenuTop_emClick(source,e)}";
      settings.ItemLinkMode = ItemLinkMode.ContentBounds;
  }).GetHtml()
        </div>

@Html.Hidden("hdalbumId", ViewData["albumId"])
@Html.Hidden("hdalbumClsNo", ViewData["albumClsNo"])
@Html.Partial("PicListPartial", Model)


@Html.DevExpress().LoadingPanel(settings =>
    {
        settings.Name = "lpLoad";
        settings.Modal = true;
        settings.Text = "数据读取中...";
    }).GetHtml()



@Html.DevExpress().PopupControl(
settings =>
{
    settings.Name = "photoModalMode";
    settings.Width = 800;
    settings.Height = 430;
    settings.AllowDragging = true;
    settings.CloseAction = CloseAction.CloseButton;
    settings.EnableAnimation = false;
    settings.HeaderText = "照片";
    settings.Modal = true;
    settings.PopupHorizontalAlign = PopupHorizontalAlign.WindowCenter;
    settings.PopupVerticalAlign = PopupVerticalAlign.WindowCenter;
    settings.SetContent(() =>
    {
        ViewContext.Writer.Write("<iframe  id='photoContent' name='photoContent' style='width:800px;height:330px' frameborder='0' ></iframe>");
    });
}).GetHtml()



@Html.DevExpress().PopupControl(
settings =>
{
    settings.Name = "picEditModalMode";
    settings.Width = 500;
    settings.Height = 360;
    settings.AllowDragging = true;
    settings.CloseAction = CloseAction.CloseButton;
    settings.EnableAnimation = false;
    settings.HeaderText = "照片修改";
    settings.Modal = true;
    settings.PopupHorizontalAlign = PopupHorizontalAlign.WindowCenter;
    settings.PopupVerticalAlign = PopupVerticalAlign.WindowCenter;
    settings.ShowFooter = true;
    settings.SetFooterTemplateContent(s =>
    {
        ViewContext.Writer.Write("<table align='center'><tr><td>");
        Html.DevExpress().Button(footBtnSettings =>
        {
            footBtnSettings.Name = "btnPicEditOK";
            footBtnSettings.Text = "确定";
            footBtnSettings.ClientSideEvents.Click = "function(s,e){picEditContent.Save()}";
            footBtnSettings.Images.Image.Url = Url.Content("~/Content/ControlImages/ok.png");
            footBtnSettings.CausesValidation = false;
        }).GetHtml();
        ViewContext.Writer.Write("</td><td>");
        Html.DevExpress().Button(footBtnSettings =>
        {
            footBtnSettings.Name = "btnPicEditCancel";
            footBtnSettings.Text = "取消";
            footBtnSettings.ClientSideEvents.Click = "picEditModalModeCancel";
            footBtnSettings.Images.Image.Url = Url.Content("~/Content/ControlImages/no.png");
            footBtnSettings.CausesValidation = false;
        }).GetHtml();
        ViewContext.Writer.Write("</td></tr></table>");

    });
    settings.SetContent(() =>
    {
        ViewContext.Writer.Write("<iframe  id='picEditContent' name='picEditContent' style='width:100%;height:300px' frameborder='0' ></iframe>");
    });

}).GetHtml()


@Html.DevExpress().LoadingPanel(settings =>
{
    settings.Name = "lpModal";
    settings.Modal = true;
    settings.Text = "数据保存中...";
}).GetHtml()

</body>
</html>